package com.flying.oop.poly;

/**
 * @ClassName: Person
 * @author: 刘鹏飞
 * @date 2023/7/168:36
 * @Description: 人类
 */
public class Person /*implements Comparable<Person>*/ {
    public int x = 10;
    private String name;
    private int age;

    private int id;


    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Person(int id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public void sleep() {
        System.out.println("人正在睡觉");
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
//        if (o == null || getClass() != o.getClass()) return false;
        if (!(o instanceof Person)) return false;
        Person person = (Person) o;
        return id == person.id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

/*
    @Override
    public int compareTo(Person o) {
*/
/*        if (age>o.age) return 100;
        else if(age<o.age) return -100;
        return 0;*//*

        return id-o.id;
    }
*/


    @Override
    public String toString() {
        return "Person{" +
               "age=" + age +
               ", id=" + id +
               ",name='" + name + '\'' +
               '}';
    }
}
